package com.example.a02glide.utils;

import android.view.Gravity;
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.widget.AppCompatTextView;

import com.example.a02glide.R;
import com.example.a02glide.application.App;


public class ToastUtils {
    private static Toast sToast;

    public static void show(String text) {
        sToastCancel();
        sToast = Toast.makeText(App.sContext, text, Toast.LENGTH_SHORT);
        sToast.show();
    }

//    public static void show2(String text) {
//        sToastCancel();
//        sToast = new Toast(App.sContext);
//        View view = View.inflate(App.sContext, R.layout.toast_layout, null);
//        AppCompatTextView tv_content = view.findViewById(R.id.tv_content);
//        tv_content.setText(text);
//        sToast.setGravity(Gravity.CENTER, 0, 0);
//        sToast.setDuration(Toast.LENGTH_SHORT);
//        sToast.setView(view);
//        sToast.show();
//
//    }

    private static final void sToastCancel() {
        if (sToast != null) {
            sToast.cancel();
            sToast = null;
        }
    }


}
